<?php
require('../home/config.php');
$iCat = base64_decode(getValue('iCat','str','POST',''));
if(!$iCat){
    return false;
}
$db = new DBQuery;
//Đếm số bản ghi
$total_record = $db->numRecord('SELECT new_id FROM news WHERE new_cat_id = '.$iCat);
// khai báo Phân trang
$page_size = 3;
$page_current = getValue('page_current','int','POST',0);
if($total_record%$page_size){
	$page_total = ($total_record - $total_record%$page_size)/$page_size+1;
}
else
    $page_total = $total_record/$page_size;
//end --- khai báo phân trang
if($page_current <= $page_total - 1){
//Select các bản ghi
$catnews = $db->query('SELECT   new_id,
                                new_title,
                                new_image,
                                new_content_summary,
                                new_date 
                                FROM news 
                       WHERE new_cat_id = '.$iCat. ' 
                       ORDER BY new_date DESC 
                       LIMIT '.($page_current*$page_size).','.$page_size);


?>
<?php if($catnews) foreach($catnews as $anew):?>
	<div class="news1">
		<img class="fl" src="<?php echo ($anew['new_image']) ? $path_img_news . $anew['new_image'] : $path_img_site.'noimages.png'?>"/>
		<h2 class="news1Title"><a href="/home/news_detail.php?id=<?php echo $anew['new_id']?>"><?php echo $stringhelper->CropWord($anew['new_title'],10)?></a></h2>
		<div class="newsCont"><?php  echo $stringhelper->CropWord($anew['new_content_summary'],50)?></div>
	</div>
<?php 
endforeach;
}?>